package com.ly.juc;
import	java.util.concurrent.ThreadPoolExecutor;

import java.util.concurrent.CountDownLatch;

/**
 * @Classname TestCountDownLatch
 * @Description TODO
 * @Date 2020/10/4 16:35
 * @Author 冷心影翼
 */
public class TestCountDownLatch {



	public static void main(String[] args) throws InterruptedException {
//		countDownLatch();

		System.out.println(-1<<1);
	}

	public static void countDownLatch() throws InterruptedException {
		School school = new School();
		for(int i=0;i<school.number;i++) {
			new Thread(()->{
				school.goHome();
			}).start();
		}
		school.closeSchool();

	}
}

class School {
	int number = 10;

	CountDownLatch countDownLatch = new CountDownLatch(number);

	public void goHome() {
		System.out.println(Thread.currentThread().getName()+" go home");
	    countDownLatch.countDown();
	}

	public void closeSchool() throws InterruptedException {

		countDownLatch.await();
		System.out.println("closeSchool");
	}
}